import React, { useState } from 'react';
import { Button, Table } from 'antd';
import { SettingOutlined } from '@ant-design/icons';
const { Column } = Table;

export default function shopTable(props) {
  const [selectionType, setSelectionType] = useState('checkbox');
  const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
      const delData = [];
      selectedRows.forEach((item) => {
        delData.push(item.id);
      });
      props.delData(delData);
    },
  };
  const open = (value) => {
    props.showDrawer2(true);
    props.findUpdataId(value);
  };
  return (
    <>
      <Table
        dataSource={props.goodData.children}
        rowSelection={{ type: selectionType, ...rowSelection }}
        style={{ marginTop: '60px' }}
        pagination={{ pageSize: 5 }}
        scroll={{ y: 440 }}
      >
        <Column title="key" dataIndex="key" key="key" />
        <Column title="title" dataIndex="title" key="title" />
        <Column title="status" dataIndex="status" key="status" />
        <Column
          title="Action"
          key="action"
          render={(text, record) => (
            <Button
              onClick={() => open(text)}
              icon={<SettingOutlined />}
            ></Button>
          )}
        />
      </Table>
    </>
  );
}
